package com.ds.yuntukubackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ds.yuntukubackend.model.dto.picture.*;
import com.ds.yuntukubackend.model.entity.Picture;
import com.ds.yuntukubackend.model.entity.User;
import com.ds.yuntukubackend.model.vo.PictureVO;

import javax.servlet.http.HttpServletRequest;

/**
* @author lenovo
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-02-02 17:12:08
*/
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     * @param inputSource  图片或url,
     * @param pictureUploadRequest 图片id,没有就是新增图片，有就是重新上传，需把之前的删掉
     * @param loginUser 当前用户，判断权限
     * @return
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * 删除图片
     * @param pictureId
     * @param loginUser
     */
    void deletePicture(long pictureId, User loginUser);

    /**
     * 编辑图片
     * @param pictureEditRequest
     * @param loginUser
     * @return
     */
    boolean editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 通过id查询图片
     * @param id
     * @param loginUser
     * @return
     */
    Picture getPictureById(long id, User loginUser);

    /**
     * 根据Picture的字段获取查询条件
     * @param pictureQueryRequest 可获取查询条件的用户字段
     * @return 查询条件queryWrapper
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);


    /**
     * 获取单个图片封装，关联用户信息
     * @param picture
     * @return
     */
    PictureVO getPictureVO(Picture picture);

    /**
     * 分页获取图片封装
     * @param picturePage
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage);

    /**
     * 分页获取图片封装
     * @param pictureQueryRequest
     * @param loginUser
     * @return
     */
    Page<Picture> listPictureByPage(PictureQueryRequest pictureQueryRequest,
                                      User loginUser);

    /**
     * 校验图片
     * @param picture
     */
    void validPicture(Picture picture);


    /**
     * 审核图片
     * @param pictureReviewRequest
     * @param loginUser
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 填充审核参数
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量上传图片
     * @param pictureUploadByBatchRequest
     * @param loginUser
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest
                         ,User loginUser);


    /**
     * 清除图片文件
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);


    /**
     * 判断用户是否可以看到该图片
     * 删除和修改图片的权限校验也是一样的
     * @param loginUser
     * @param picture
     */
    void checkPictureAuth(User loginUser, Picture picture);
}

